package com.zone.domain.strategy.service.armory.assemble.impl;

import com.zone.domain.strategy.model.entity.StrategyAwardEntity;
import com.zone.domain.strategy.repository.IStrategyRepository;
import com.zone.domain.strategy.service.armory.assemble.IStrategyAssembleHandler;
import com.zone.types.utils.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: zongzi
 * @description: 库存数据装配处理器
 * @date: 2024/6/15
 */
@Slf4j
@Service
public class AwardStockAssembleHandler implements IStrategyAssembleHandler {
    @Autowired
    private IStrategyRepository strategyRepository;

    @Override
    public void assembleStrategy(Long strategyId, List<StrategyAwardEntity> strategyAwardEntityList) {
        if (CollectionUtils.isEmpty(strategyAwardEntityList)) {
            return;
        }
        // 装配库存数据
        strategyAwardEntityList.forEach(strategyAwardEntity -> strategyRepository.assembleStockData(strategyId, strategyAwardEntity.getAwardId(), strategyAwardEntity.getAwardCount()));
    }
}
